package com.ruihu.admin.common.constant;

import com.ruihu.admin.common.domain.BaseEnum;

import java.util.Arrays;
import java.util.Optional;

public enum SuccessEnum implements BaseEnum {
    SUCCESS("Success", "成功"),

    FAIL("Fail", "失败");

    private String value;
    private String desc;

    SuccessEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public String getValue() {
        return value;
    }
    @Override
    public String getDesc() {
        return desc;
    }

    public static SuccessEnum valueOf(Integer status) {
        SuccessEnum[] values = SuccessEnum.values();
        Optional<SuccessEnum> first = Arrays.stream(values).filter(e -> e.getValue().equals(status)).findFirst();
        return !first.isPresent() ? null : first.get();
    }

    public static boolean isExist(Integer status) {
        SuccessEnum successEnum = valueOf(status);
        return successEnum != null;
    }
}
